﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using TireService.Data;

namespace TireService.Website
{
    public partial class WebsiteSubMenu : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Login1_LoggedIn(object sender, EventArgs e)
        {
            // Fetch customer id
            try
            {
                Guid userid = new Guid(Membership.GetUser(Login1.UserName).ProviderUserKey.ToString());

                TireServiceDB db = new TireServiceDB();

                int CustomerId = db.GetCustomerIdByUserId(userid);

                // Set session
                Session["CustomerId"] = CustomerId;
            }
            catch (Exception ex)
            {
                // Error occured - logout user again
                FormsAuthentication.SignOut();

                Response.Redirect("~/Index.aspx");
            }
        }

        //protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        //{
        //    if (e.Authenticated)
        //    {
		 
        //    }
        //}
    }
}